package com.jzo2o.foundations.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jzo2o.common.model.PageResult;
import com.jzo2o.foundations.mapper.ServeMapper;
import com.jzo2o.foundations.model.domain.Serve;
import com.jzo2o.foundations.model.dto.request.ServePageQueryReqDTO;
import com.jzo2o.foundations.model.dto.response.ServeResDTO;
import com.jzo2o.foundations.service.IServeService;
import com.jzo2o.mysql.utils.PageHelperUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 区域服务业务层实现类
 *
 * @Author Yjr
 * @Date 2025/6/30 15:56
 */
@Service
@Slf4j
public class ServeServiceImpl extends ServiceImpl<ServeMapper, Serve> implements IServeService {

    /**
     * 区域服务分页查询
     *
     * @param dto
     * @return
     */
    @Override
    public PageResult<ServeResDTO> pageList(ServePageQueryReqDTO dto) {
        return PageHelperUtils.selectPage(dto,
                ()->baseMapper.pageList(dto.getRegionId()));

//        PageHelper.startPage(dto.getPageNo().intValue(), dto.getPageSize().intValue());
//        Page<ServeResDTO> page = (Page<ServeResDTO>) baseMapper.pageList(dto.getRegionId());
//        PageResult<ServeResDTO> pageResult = new PageResult<>();
//        pageResult.setList(page.getResult());
//        pageResult.setTotal(page.getTotal());
//        Double v = Math.ceil(page.getTotal() / (double)(dto.getPageSize()));
//        pageResult.setPages(v.longValue());
//        return pageResult;
    }
}
